<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
    <title>主页示例</title>


    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.0.1/css/bootstrap.min.css" rel="stylesheet">

</head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.0.1/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.0.1/js/button.min.js"></script>
<script>
$(document).ready(function(){
	
	htmlobj=$.ajax({
		url:"GetPackagesServlet",
		async:false,
		dataType:"text"
	});
// 	alert(htmlobj.responseText);
	var rows = htmlobj.responseText;
	//alert(rows);
	var rowsArray = rows.split('\n');
	rowsArray.pop();
 	//alert(rowsArray.length);
	for (var j in rowsArray){
		var str = rowsArray[j];
		//alert(str);
		var strArray  = str.split('|')
		var rowStr = "<tr>";
        strArray[0] = "<a id='data"+j+"' href='#'>" + strArray[0] + "</a>";
	    for(var i in strArray){
	    	rowStr = rowStr + "<td>"+strArray[i]+"</td>";
	//         alert(strArray[i]);
	    }
		rowStr = rowStr + "<td><input type='text' class='form-control'/></td><td> <button type='button' class='btn btn-default submit-btn'>运行</button></td></tr>";
// 		alert(rowStr);
		$("#show-table").append(rowStr);
        $("#data"+j).click(function () {
            var htmlobj = $.ajax({
                url:"GetPackageInfoServlet",
                async:false,
                type:"get",
                data:{
                    "jarName":$(this).html()
                }
            });
            alert(htmlobj.responseText)
        });
	}
	
	$(".submit-btn").click(function(){
		var name = $(this).parent().parent().children().eq(0).text();
		var input = $(this).parent().parent().children().eq(3).children().val();
		//alert(input);
		
		var htmlobj = $.ajax({
			url:"ExecuteJobServlet",
			async:false,
			type:"post",
			 data:{
                  "jarName":name,
                  "inPath":input
              }
		});
		alert(htmlobj.responseText)
	});
});
</script>
<body>

    <div class="container">
        <div class="row clearfix">
            <div class="col-md-12 column">
                <table class="table table-hover table-striped" >
                    <thead>
                        <tr>
                    
                            <th>
                                Name
                            </th>
                            <th>
                                Length
                            </th>
                            <th>
                               Date
                            </th>
                            <th>
                           input路径 
                            </th>
                            <th>
                            操作
                            </th>
                           
                        </tr>
                    </thead>
                    <tbody id="show-table">

                    </tbody>
                </table>
            </div>
        </div>
    </div>
</body>

</html>